Return to start page

Core/Environment/Library Sound.j

Code

		
1			library ALibraryCoreEnvironmentSound
2
3 /**
4 * Plays a sound for the player @param user.
5 * @author Tamino Dauth
6 * @param user Player who the sound is played for.
7 * @param usedSound Played sound.
8 */
9 function PlaySoundForPlayer takes player user, sound usedSound returns nothing
10 local player localPlayer = GetLocalPlayer()
11 if (user == localPlayer) then
12 call StartSound(usedSound)
13 endif
14 set localPlayer = null
15 endfunction
16
17 /// Plays a sound for the player user by its file path.
18 /// Note that sound paths has to be preloaded before they can be played.
19 /// Otherwise the sound will just be played for the second time.
20 /// @author Tamino Dauth
21 /// @param user Player who can hear the sound.
22 /// @param soundPath Played sound file.
23 function PlaySoundPathForPlayer takes player user, string soundPath returns nothing
24 local sound usedSound = CreateSound(soundPath, false, false, true, 12700, 12700, "")
25 call PlaySoundForPlayer(user, usedSound)
26 call KillSoundWhenDone(usedSound)
27 set usedSound = null
28 endfunction
29
30 /// Preloads a sound file by its path.
31 /// Note that sound paths has to be preloaded before they can be played.
32 /// Otherwise the sound will just be played for the second time.
33 /// @author Tamino Dauth
34 /// @param soundPath Preloaded sound file.
35 function PreloadSoundPath takes string soundPath returns nothing
36 local sound usedSound = CreateSound(soundPath, false, false, false, 10, 10, "")
37 call SetSoundVolume(usedSound, 0)
38 call StartSound(usedSound)
39 call KillSoundWhenDone(usedSound)
40 set usedSound = null
41 endfunction
42
43 endlibrary